////
////  NetworkSingleton.m
////  meituan
////
////  Created by jinzelu on 15/6/17.
////  Copyright (c) 2015年 jinzelu. All rights reserved.
////
//
//#import "NetworkSingleton.h"
//
//@implementation NetworkSingleton
//
//+(NetworkSingleton *)sharedManager{
//    static NetworkSingleton *sharedNetworkSingleton = nil;
//    static dispatch_once_t predicate;
//    dispatch_once(&predicate,^{
//        sharedNetworkSingleton = [[self alloc] init];
//    });
//    return sharedNetworkSingleton;
//}
//-(AFHTTPSessionManager *)baseHtppRequest{
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//    [manager.requestSerializer setTimeoutInterval:TIMEOUT];
//    //header 设置
//    //[manager.requestSerializer setValue:K_PASS_IP forHTTPHeaderField:@"Host"];
//    [manager.requestSerializer setValue:@"max-age=0" forHTTPHeaderField:@"Cache-Control"];
//    [manager.requestSerializer setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"];
//    [manager.requestSerializer setValue:@"zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3" forHTTPHeaderField:@"Accept-Language"];
//    [manager.requestSerializer setValue:@"gzip, deflate" forHTTPHeaderField:@"Accept-Encoding"];
//    //[manager.requestSerializer setValue:@"keep-alive" forHTTPHeaderField:@"Connection"];
//    [manager.requestSerializer setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:35.0) Gecko/20100101 Firefox/35.0" forHTTPHeaderField:@"User-Agent"];
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain", @"text/html", @"application/json",@"text/json",@"text/xml", @"text/javascript", nil];
//    
//    return manager;
//}
//#pragma mark - 微信
//- (void)weiXinNetworkPostRequestLibrary:(NSString *)params commonRequestUrl:(NSString *) requestUrl successBlock:(SuccessBlock)successBlock failureBlock:(FailureBlock)failureBlock{
//    AFSecurityPolicy *securityPolicy = [[AFSecurityPolicy alloc] init];
//    [securityPolicy setAllowInvalidCertificates:YES];
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSCharacterSet *encodeUrlSet = [NSCharacterSet URLQueryAllowedCharacterSet];
//    NSString *urlStr = [requestUrl stringByAddingPercentEncodingWithAllowedCharacters:encodeUrlSet];
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"网络错误");
//    }];
//}
//#pragma mark - 共通请求类 POST 注册 是否已注册
//- (void)commonNetworkPostRequestLibrary:(NSDictionary *)params commonRequestUrl:(NSString *) requestUrl successBlock:(SuccessBlock)successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSCharacterSet *encodeUrlSet = [NSCharacterSet URLQueryAllowedCharacterSet];
//    NSString *urlStr = [requestUrl stringByAddingPercentEncodingWithAllowedCharacters:encodeUrlSet];
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"网络错误");
//    }];
//}
//#pragma mark - 共通请求类 GET 是否已注册
//- (void)commonNetworkGetRequestLibrary:(NSDictionary *)params commonRequestUrl:(NSString *) requestUrl successBlock:(SuccessBlock)successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSCharacterSet *encodeUrlSet = [NSCharacterSet URLQueryAllowedCharacterSet];
//    NSString *urlStr = [requestUrl stringByAddingPercentEncodingWithAllowedCharacters:encodeUrlSet];
//    [manager GET:urlStr parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"网络错误");
//    }];
//}
//
//- (void)commonNetworkWithHUDPostRequestLibrary:(NSDictionary *)params commonRequestUrl:(NSString *) requestUrl successBlock:(SuccessBlock)successBlock failureBlock:(FailureBlock)failureBlock{
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
//    [SVProgressHUD show];
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSCharacterSet *encodeUrlSet = [NSCharacterSet URLQueryAllowedCharacterSet];
//    NSString *urlStr = [requestUrl stringByAddingPercentEncodingWithAllowedCharacters:encodeUrlSet];
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        [SVProgressHUD dismiss];
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"网络错误");
//    }];
//}
//
//- (void)commonNetworkWithHUDcommonRequestUrl:(NSString *) requestUrl successBlock:(SuccessBlock)successBlock failureBlock:(FailureBlock)failureBlock{
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
//    [SVProgressHUD show];
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSCharacterSet *encodeUrlSet = [NSCharacterSet URLQueryAllowedCharacterSet];
//    NSString *urlStr = [requestUrl stringByAddingPercentEncodingWithAllowedCharacters:encodeUrlSet];
//    [manager GET:urlStr parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        [SVProgressHUD dismiss];
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"网络错误");
//    }];
//}
//
//#pragma mark - 获取机票订单
//- (void)getFlightOrderInfo:(NSDictionary *)params flightInfoOrder:(NSString *) flightInfoOrder successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [flightInfoOrder stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//#pragma mark - 机票订单存储到数据库
//- (void)saveFlightOrderToSql:(NSDictionary *)params sqlUrl:(NSString *) sqlUrl successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [sqlUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        successBlock(responseObject);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//#pragma mark - 自动支付机票订单
//- (void)payForFlightOrder:(NSDictionary *)params OrderInfo:(NSString *) OrderInfo successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [OrderInfo stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//
//#pragma mark - 飞机票购买成功后发送短信
//- (void)sendFlightTicketMsg:(NSDictionary *)params message:(NSString *) message successBlock:(SuccessBlock) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    [manager GET:message parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSString *errorStr = [error.userInfo objectForKey:@"NSLocalizedDescription"];
//        failureBlock(errorStr);
//    }];
//}
//
//#pragma mark - 获取机票订单信息
//- (void)getUserOrderFlightInfo:(NSDictionary *)params orderUrl:(NSString *) orderUrl successBlock:(SuccessBlock) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [orderUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    [manager GET:urlStr parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        id result = [responseObject objectFromJSONData];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSString *errorStr = [error.userInfo objectForKey:@"NSLocalizedDescription"];
//        failureBlock(errorStr);
//    }];
//}
//
//
//#pragma mark - 删除选中机票订单
//- (void)deleteFlightOrderFromSql:(NSDictionary *)params deleteSqlUrl:(NSString *) deleteSqlUrl successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [deleteSqlUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        successBlock(responseObject);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//#pragma mark - 获取机票订单的详细信息
//- (void)getFlightOrderDetailInfo:(NSDictionary *)params flightInfo:(NSString *) flightInfo successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [flightInfo stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        //        successBlock(responseObject);
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        NSData *resultData = [result dataUsingEncoding:NSUTF8StringEncoding];
//        id resultId = [resultData objectFromJSONData];
//        successBlock(resultId);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//#pragma mark - 获取火车票订单列表
//- (void)getTrainTicketOrderList:(NSDictionary *)params trainInfo:(NSString *) trainInfo successBlock:(SuccessBlock) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    NSString *urlStr = [trainInfo stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    [manager GET:urlStr parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        successBlock(responseObject);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSString *errorStr = [error.userInfo objectForKey:@"NSLocalizedDescription"];
//        failureBlock(errorStr);
//    }];
//}
//
//
//#pragma mark - 删除火车票订单信息
//- (void)deleteTrainTickectInfoFromSql:(NSDictionary *)params ticketInfo:(NSString *) ticketInfo successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [ticketInfo stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        successBlock(responseObject);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//#pragma mark - 更新用户信息
//- (void)saveTrainTickectInfoToSql:(NSDictionary *)params ticketInfo:(NSString *) ticketInfo successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock
//{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [ticketInfo stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        successBlock(responseObject);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//#pragma mark - 提交火车票订单
//- (void)postTrainTicket:(NSDictionary *)params ticketInfo:(NSString *) ticketInfo successBlock:(SuccessBlock) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [ticketInfo stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        id result = [responseObject objectFromJSONData];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//
//#pragma mark - 获取火车票检索列表
//- (void)getTrainTicketInfoList:(NSDictionary *)params searchInfo:(NSString *) searchInfo successBlock:(SuccessBlock) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [searchInfo stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    [manager GET:urlStr parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        id result = [responseObject objectFromJSONData];
//        successBlock(result);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSString *errorStr = [error.userInfo objectForKey:@"NSLocalizedDescription"];
//        failureBlock(errorStr);
//    }];
//}
//
//#pragma mark - 请求游戏地址
//- (void)requestPingAnGameUrl:(NSDictionary *)params gameUrl:(NSString *)gameUrl successBlock:(SuccessBlock) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [gameUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        //        successBlock(responseObject);
//        NSString *result = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
//        NSData *resultData = [result dataUsingEncoding:NSUTF8StringEncoding];
//        id resultId = [resultData objectFromJSONData];
//        successBlock(resultId);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//    
//}
//
//
//#pragma mark - 获取手机号码归属地
//- (void)getPhoneArea:(NSDictionary *)params areaUrl:(NSString *) areaUrl successBlock:(SuccessBolckStr) successBlock failureBlock:(FailureBlock)failureBlock{
//    AFHTTPSessionManager *manager = [self baseHtppRequest];
//    //manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    NSString *urlStr = [areaUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    
//    [manager POST:urlStr parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
//        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:enc];
//        NSRange range = [responseStr rangeOfString:@"|"];
//        NSString *area = [responseStr substringFromIndex:range.location+1];
//        successBlock(area);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failureBlock(@"登陆失败");
//    }];
//}
//
//@end
